#include "SamplesList.h"
#include "TriangleSample.h"
#include "DefaultSample.h"
#include "imgui.h"
#include "EditorSample.h"
#include "TextureSample.h"
SamplesList::SamplesList(Graphics& gfx) : gfxRef(gfx)
{
	this->sample = nullptr;
}

SamplesList::~SamplesList()
{
	if (sample!= nullptr)
	{
		delete sample;
		sample = nullptr;
	}
}

void SamplesList::GUI()
{
	ImGui::Begin("SampleList");
	if (sample)
	{
		sample->GUI();
		ImGui::Separator();
		if (ImGui::Button("Close"))
		{
				delete sample;
				sample = nullptr;
		}
	}
	else
	{
		if (ImGui::Button("Triangle"))
		{
			sample = new TriangleSample(gfxRef);
		}

		if (ImGui::Button("Node Editor"))
		{
			sample = new EditorSample(gfxRef);
		}

		if (ImGui::Button("Texture"))
		{
			sample = new TextureSample(gfxRef);
		}
	}
	
	ImGui::End();
}

void SamplesList::Render(float dt)
{
	if (sample)
	{
		sample->Render(dt);
	}
}

void SamplesList::Update(float dt)
{
	if (sample)
	{
		sample->Update(dt);
	}
}
